@use "mixins";
@use "vars";

/**
 * Page Content
 * Styles specific to blocks used within page content.
 */

.page-content {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  overflow-wrap: break-word;
  position: relative;
  .align-left {
    text-align: left;
  }
  img.align-left, table.align-left, iframe.align-left, video.align-left {
    float: left !important;
    margin: vars.$xs vars.$m vars.$m 0;
  }
  .align-right {
    text-align: right !important;
  }
  img.align-right, table.align-right, iframe.align-right, video.align-right {
    float: right !important;
    margin: vars.$xs 0 vars.$xs vars.$s;
  }
  .align-center {
    text-align: center;
  }
  img.align-center, video.align-center, iframe.align-center {
    display: block;
  }
  img.align-center, table.align-center, iframe.align-center, video.align-center {
    margin-left: auto;
    margin-right: auto;
  }
  .align-justify {
    text-align: justify;
  }
  h1, h2, h3, h4, h5, h6, pre {
    clear: left;
  }
  hr {
    clear: both;
    margin: vars.$m 0;
  }
  table {
    hyphens: auto;
    table-layout: fixed;
    max-width: 100%;
    height: auto !important;
  }

  // diffs
  ins,
  del {
    text-decoration: none;
  }
  ins {
    background: #dbffdb;
  }
  del {
    background: #FFECEC;
  }

  details {
    border: 1px solid;
    @include mixins.lightDark(border-color, #DDD, #555);
    margin-bottom: 1em;
    padding: vars.$s;
  }
  details > summary {
    margin-top: -(vars.$s);
    margin-left: -(vars.$s);
    margin-right: -(vars.$s);
    margin-bottom: -(vars.$s);
    font-weight: bold;
    @include mixins.lightDark(background-color, #EEE, #333);
    padding: vars.$xs vars.$s;
  }
  details[open] > summary {
    margin-bottom: vars.$s;
    border-bottom: 1px solid;
    @include mixins.lightDark(border-color, #DDD, #555);
  }
  details > summary + * {
    margin-top: .2em;
  }
  details:after {
    content: '';
    display: block;
    clear: both;
  }

  li > input[type="checkbox"] {
    vertical-align: top;
    margin-top: 0.3em;
  }

  p:empty {
    min-height: 1.6em;
  }

  &.page-revision {
    pre code {
      white-space: pre-wrap;
    }
  }

  .cm-editor {
    margin-bottom: 1.375em;
  }

  video, iframe {
    max-width: 100%;
  }

  a {
    text-decoration: underline;
  }
}

// This is seperated out so we can target it out-of-editor by default
// and use advanced (:not) syntax, not supported by things like PDF gen,
// to target in-editor scenarios to handle edge-case of TinyMCE using an
// image for data placeholders where we'd want height attributes to take effect.
body .page-content img,
.page-content img:not([data-mce-object]) {
  max-width: 100%;
  height:auto;
}

/**
 * Callouts
 * Some styles duplicated for supporting logical units (eg. inline-end) while
 * providing fallbacks to non-logical rules, so RTL is natively supported where possible.
 */
.callout {
  border-left: 3px solid #BBB;
  border-inline-start: 3px solid #BBB;
  border-inline-end: none;
  background-color: #EEE;
  padding: vars.$s;
  padding-left: vars.$xl;
  padding-inline-start: vars.$xl;
  padding-inline-end: vars.$s;
  display: block;
  position: relative;
  overflow: auto;
  &:before {
    background-image: url('');
    background-repeat: no-repeat;
    content: '';
    width: 1.2em;
    height: 1.2em;
    left: vars.$xs + 2px;
    inset-inline-start: vars.$xs + 2px;
    inset-inline-end: unset;
    top: 50%;
    margin-top: -9px;
    display: inline-block;
    position: absolute;
    line-height: 1;
    opacity: 0.8;
  }
  &.success {
    @include mixins.lightDark(border-color, vars.$positive, vars.$positive-dark);
    @include mixins.lightDark(background-color, #eafdeb, #122913);
    @include mixins.lightDark(color, #063409, vars.$positive-dark);
  }
  &.success:before {
    background-image: url("");
  }
  &.danger {
    @include mixins.lightDark(border-color, vars.$negative, vars.$negative-dark);
    @include mixins.lightDark(background-color, #fcdbdb, #250505);
    @include mixins.lightDark(color, #4d0706, vars.$negative-dark);
  }
  &.danger:before {
    background-image: url("");
  }
  &.info {
    @include mixins.lightDark(border-color, vars.$info, vars.$info-dark);
    @include mixins.lightDark(background-color, #d3efff, #001825);
    @include mixins.lightDark(color, #01466c, vars.$info-dark);
  }
  &.warning {
    @include mixins.lightDark(border-color, vars.$warning, vars.$warning-dark);
    @include mixins.lightDark(background-color, #fee3d3, #30170a);
    @include mixins.lightDark(color, #6a2802, vars.$warning-dark);
  }
  &.warning:before {
    background-image: url("");
  }
  a {
    color: inherit;
    text-decoration: underline;
  }
}